package com.hq.sso.controller;

import com.hq.sso.utils.CookieUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName IndexController
 * @Description 首页
 * @Author huangzl
 * @Date 2018/10/17 15:56
 * @Version 1.0
 **/
@Controller
public class IndexController {


    @Value("${sso.login}")
    private String loginUrl;

    @RequestMapping("/")
    public String index(HttpServletRequest request) {
        String callback = loginUrl + "http://java-client.net/auth/index";
        System.out.println(callback);
        request.setAttribute("loginUrl", callback);
        return "index";
    }

    @RequestMapping("/logout")
    @ResponseBody
    public String logout(HttpServletRequest request){
        request.getSession(true).removeAttribute("Account");
        return "ok";
    }

}